using DataTestFramework.NHibernate.Models;

using FluentNHibernate.Mapping;

using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;


namespace DataTestFramework.NHibernate.Mappers
{
    public class NhProductMapping : ClassMap<NhProduct>
    {
        public NhProductMapping()
        {
            Table("Products");
            Id(m => m.ProductId).GeneratedBy.Identity();
            Map(m => m.ProductName).Length(50).Not.Nullable();
            Map(m => m.Unit).Length(10).Not.Nullable();
            Map(m => m.UnitPrice);
            Map(m => m.Remark);
            Map(m => m.Quantity);
            Map(m => m.CategoryId);
            References(m => m.Category).Column("CategoryId").ForeignKey("CategoryId").LazyLoad();
            HasMany(m => m.OrderDetails).KeyColumn("DetailId").LazyLoad();
        }
    }
}
